function $http(url, data) {
    const prefix = window.location.href.includes('localhost') ? '/proxy' : 'http://118.25.208.216:8002'
    const headers = {
        'Content-Type': 'application/json',
    }
    const token = sessionStorage.getItem('token')
    if (token) {
        headers.Authorization = 'Token ' + token
    }
    return fetch(prefix + url, {
        method: 'post',
        headers,
        body: JSON.stringify(data)
    }).then(res => {
        if (res.status === 401) {
            window.location.href = './login.html'
        }
        return res.json()
    })
}